package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author 李明洋
 * @date 2025/3/26 9:26
 * @version: 1.0
 */
public class JDBCDemo10 {
    public static void main(String[] args) {
        try (Connection connection = DBUti1.getconnection();){
            connection.setAutoCommit(false);
            String sql = "delete from user where id=?";
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setInt(1,4);

            int num = ps.executeUpdate();
            System.out.println(num>0?"成功":"失败");
            connection.commit();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
